package org.kabeja.dxf.entity;

import org.kabeja.dxf.DXFConstants;
import org.kabeja.dxf.helpers.Point;
import org.kabeja.math.ParametricPlane;

/**
 * @author shutao
 * @since 2022/4/24 17:39
 */
public class DXFCircle extends DXFEntity {
    private Point center;
    private double radius;

    public DXFCircle() {
        this.setLineType(this.getType());
    }

    public double getRadius() {
        return this.radius;
    }

    public void setRadius(double var1) {
        this.radius = var1;
    }

    public void setCenterPoint(Point var1) {
        this.center = var1;
    }

    public Point getCenterPoint() {
        return this.center;
    }

    @Override
    public Bounds getBounds() {
        Bounds var1 = new Bounds();
        ParametricPlane var2 = new ParametricPlane(this.getExtrusion());
        Point var3 = var2.getPoint(this.center.getX(), this.center.getY());
        var1.setMaximumX(var3.getX() + this.radius);
        var1.setMinimumX(var3.getX() - this.radius);
        var1.setMaximumY(var3.getY() + this.radius);
        var1.setMinimumY(var3.getY() - this.radius);
        return var1;
    }

    @Override
    public String getType() {
        return DXFConstants.ENTITY_TYPE_CIRCLE;
    }

    @Override
    public double getLength() {
        return 6.283185307179586D * this.radius;
    }

    public Point getPointAt(double var1) {
        double var3 = this.radius * Math.cos(Math.toRadians(var1));
        double var5 = this.radius * Math.sin(Math.toRadians(var1));
        ParametricPlane var7 = new ParametricPlane(this.getExtrusion());
        return var7.getPoint(var3 + this.center.getX(), var5 + this.center.getY());
    }
}
